﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using WMSWebApi.Implement;
using WMSWebApi.Models;

namespace WMSWebApi.Controllers
{
    [Route("api/[controller][action]")]
    [ApiController]
    public class StationController : ControllerBase
    {
        ImpStations imp = new ImpStations();
        /// <summary>
        /// 添加工位
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        [HttpGet]
        public ActionResult<string> Add(StationsTable item)
        {
            return imp.Add(item) >= 1 ? "添加成功" : "添加失败";
        }
        /// <summary>
        /// 删除工位
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpDelete]
        public ActionResult<string> Delete(int id)
        {
            return imp.Delete(id) >= 1 ? "删除成功" : "添加删除";
        }
        /// <summary>
        /// 根据工位名查询工位编号
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        [HttpPost]
        public int Get([FromBody]string value)
        {
            return imp.Get(value);
        }
        /// <summary>
        /// 获取所有工位名称
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public List<string> GetAllName()
        {
            return imp.GetAllName();
        }
        /// <summary>
        /// 查询所有工位
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public IEnumerable<StationsTable> GetAll()
        {
            return imp.GetAll();
        }
        /// <summary>
        /// 修改工位
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        [HttpPut]
        public ActionResult<string> Update(StationsTable item)
        {
            return imp.Update(item) >= 1 ? "修改成功" : "修改失败";
        }
    }
}
